import request from '@/router/axios';

let apiUrl = '/api/blade-message' // 代理接口地址
// let apiUrl = 'test'  // 后台本地接口地址


export const workOrderType = () => {
  return request({
    url: apiUrl + '/workOrderType',
    method: 'get'
  })
}

export const workOrder = (form) => {
  return request({
    url: apiUrl + '/workOrder',
    method: 'post',
    data: form
  })
}

export const myWorkOrder = (pageNo, pageSize,keyWord, orderStatus, level) => { // 我的工单列表
  return request({
    url: apiUrl + '/workOrder/page',
    method: 'get',
    params: {
      pageNo,
      pageSize,
      keyWord,
      orderStatus: orderStatus== -1 ? null : orderStatus,
      level : level== -1 ? null : level
    }
  })
}

export const deleteWorkOrder = (id) => { // 删除工单
  return request({
    url: apiUrl + `/workOrder/${id}`,
    method: 'delete'
  })
}

export const workOrderDetail = (id) => { // 删除工单
  return request({
    url: apiUrl + `/workOrder/${id}`,
    method: 'get'
  })
}

export const workOrderClose = (id) => { // 关闭工单
  return request({
    url: apiUrl + `/workOrder/close/${id}`,
    method: 'put'
  })
}

export const workOrderCommunication = (orderId, content) => { // 添加记录
  return request({
    url: apiUrl + `/workOrderCommunication/order/${orderId}`,
    method: 'post',
    data: {
      content
    }
  })
}

export const evaluate = (id, evaluateLevel, isSolved, remarks) => { // 工单评价
  return request({
    url: apiUrl + `/workOrder/evaluate/${id}`,
    method: 'put',
    data: {
      evaluateLevel,
      isSolved,
      remarks
    }
  })
}

export const acceptFeedback = (id) => { // 受理工单
  return request({
    url: apiUrl + `/workOrder/accept/${id}`,
    method: 'put'
  })
}
